Importing necesary packages¶For the graphs we are creating in this notebook the following packages were imported:
import matplotlib.pyplot as plt
import plotly
plotly.offline.init_notebook_mode()
import plotly.express as px
import plotly.graph_objects as go
import seaborn as sns
import numpy as np
BAR GRAPH: MATPLOTLY¶bar-graph created using matplotlib.# Matplotlib Bar-Graph
names = ['Suzan', 'Harry', 'Genji', 'Denver', 'Mandy']
ages = [20, 21, 19, 23, 18]
bar_colors = ['tab:red', 'tab:blue', 'tab:green', 'tab:purple', 'tab:orange']
fig, ax = plt.subplots()
ax.bar(names, ages, label=ages, color=bar_colors)
ax.set(yticks=np.arange(0, 25), xlabel='Name', ylabel='Age', title= 'Ages in a friend group')
plt.show()
PLOLTY: BAR-GRAPH¶plolty, which is a bit interactive than that of Matplotlib.Plotly Express, a high level interface to Plolty, which can operate on various data.colour = ['red', 'blue', 'green', 'purple', 'orange']
fig = px.bar(x=names, y=ages, color=colour)
fig.update_layout(title='Ages in a friend group', yaxis_title='Age',
xaxis_title='Name')
fig.show(rendered="pdf")
PIE CHART: PLOTLY¶pie-chart creating using plotly.go.Pie, where data visualized by sectors of the pie is set in values.# Plotly Pie-Chart
labels = ['Grocery', 'Rent', 'Clothing', 'Entertainment', 'Others']
values = [350, 450, 150, 100, 150]
fig = go.Figure(data=[go.Pie(labels=labels, values=values, title='Monthly Expenses')])
fig.show()
SCATTERPLOT - SEABORN¶scatterplot created using random.numpy random to generate random arrays.# Seaborn scatterplot
x = np.random.normal(size=100)
y = np.random.normal(size=100)
colors = np.random.rand(100)
sizes = 100 * np.random.rand(100)
sns.scatterplot(x=x, y=y, hue=colors, size=sizes)
<Axes: >
TABLE - PLOTLY¶plotly.go.Table which provides a Table object for viewing data.interactive.# Plotly Table
fig = go.Figure(data=[go.Table(header=dict(values=['Grocery', 'Rent', 'Clothing', 'Entertainment', 'Others'],
line_color='slategrey',fill_color='skyblue', align='left'),
cells=dict(values=[[350, 325, 330], [450, 440, 445], [150, 200, 155], [100,90, 120], [150, 400, 203]],
line_color='slategrey',fill_color='lightcyan', align='left'))])
fig.show()